<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>client系列</title>
    <style>
     
        div {
            width: 200px;
            height: 200px;
            background-color: skyblue;
            border: 10px solid red;
            padding: 11px;
        }
    </style>
</head>
<body>

    <div></div>

    <script>
        /* 
            client 和  offsetWidth 最大的区别就是 是否包含border
            clientWidth = width + padding
            clientTop = border

            offsetWidth = width + border + padding
        */
       var div = document.querySelector('div'); 
       // 242 = 200 + 10 * 2 + 11 * 2
       // offsetidth = width + border + padding
       console.log(div.offsetWidth); //242

       //  有定位的父级距离 
       console.log(div.offsetLeft);  // 8


       console.log(div.clientWidth);
       // 222 = 200 + 11 * 2
      // clientWidth = width + padding

       console.log(div.clientHeight);
        // 222 = 200 + 11 * 2
        // clientHeight = height + padding


    console.log(div.clientTop);
    console.log(div.clientLeft);
    // 10 border
    </script>
</body>
</html>